package ut

// 基于rune方式的字符串截取
func SubForRune(data string, start int, end int) string {
	runes := []rune(data)	//转换为字符数组
	return string(runes[start:end])
}

// 基于for-range方式的字符串截取
func SubForRange(data string, start int, end int) string {
	var n, startIndex, endIndex int
	for i, _ := range data {
		if n == start {
			startIndex = i
		}
		if n == end {
			endIndex = i
			break
		}
		n++
	}
	return data[startIndex:endIndex]
}
